﻿using UnityEngine;
using System.Collections;

public class WhenComeInScreen : MonoBehaviour {

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {

		Camera mainCamera = Camera.main;
		Vector3 cameraPosition = mainCamera.transform.position;
		
		//2
//		float xDist = mainCamera.aspect * mainCamera.orthographicSize; 
		float yDist = mainCamera.orthographicSize;

//		float xMax = cameraPosition.x + xDist;
//		float xMin = cameraPosition.x - xDist;

		float yMax = cameraPosition.y + yDist;
		float yMin = cameraPosition.y - yDist;

		Vector3 myPosition = gameObject.transform.position;
		if(myPosition.y < yMax && myPosition.y > yMin){
			this.enabled = false;
			gameObject.SendMessage("Logic_onEnterScreen");
		}

	}
}






